<?
// print_r($_POST); 
//外网连内部接口
// $s= new SoapClient(null,array(
// "location" => "http://open.12301.cc/openService/pft_insideMX.php",
// "uri" => "www.16u.com?ac_16u=16ucom|pw_16u=c33367701511b4f6020ec61ded352059|auth_16u=true"));
include_once '/var/www/html/new/com.inc.php';
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
$btime3 = $_POST['btime3']? $_POST['btime3'] : date('Y-m-d',strtotime('-3days'));
$lid = $_POST['lid'] ? $_POST['lid'] :'';

$n = 0;
// $aid = $_SESSION['memberID'];
//查询下单票数
for($date = $btime3;$date <= date('Y-m-d');$date = date('Y-m-d',strtotime($date)+86400)){
    $st = $date .' 00:00:00';
    $ed = $date .' 23:59:59';
    $xiax = $s -> Order_Globle_Search(
        "","", "$lid", "", "", "", "$st", "$ed", "", "",
        "", "", "", "", "", "", "", "", "1", "1",
        "0", "", "1", "0","","0","0", "0","","",
        "$aid", "", "", "", "");
    $xiati .= $xiax.',';
    $temp_date = date('Y-m-d',strtotime($date));
    $dates .= $temp_date.',';
    $n++;
    if($n>30)break;//防止死循环
}
$xiati=substr($xiati,0,-1);
// 查询已完成的订单数
for($date = $btime3;$date <= date('Y-m-d');$date = date('Y-m-d',strtotime($date)+86400)){
    $st = $date .' 00:00:00';
    $ed = $date .' 23:59:59';
    $x = $s -> Order_Globle_Search(
        "","", "$lid", "", "", "", "", "", "", "",
        "$st", "$ed", "", "", "", "", "", "", "1", "1",
        "0", "", "1", "0","","0","0", "0","","",
        "$aid", "", "", "", "");
    $ti .= $x.',';
    $temp_date = date('Y-m-d',strtotime($date));
    $dates .= $temp_date.',';
    $n++;
    if($n>30)break;//防止死循环
}

$ti2 = $ti;
$ti = substr($ti,0,-1);

//预计未来三天销量 根据订单有效期 状态未使用
for($i=1;$i<=3;$i++){

    $temp_date= date('Y-m-d',strtotime('+'.$i.'days'));
    $dates .= $temp_date.',';

    $btime2 = date('Y-m-d',strtotime('+'.$i.'days'));
    $x = $s -> Order_Globle_Search(
        "","", "$lid", "", "", "", "", "", "$btime2", "$btime2",
        "", "", "", "", "", "0", "", "", "1", "1",
        "0", "", "1", "0","","0","0", "0","","",
        "$aid", "", "", "", "");
    $ti2 .= $x.',';
}
$ti2 = substr($ti2,0,-1);

$dates = substr($dates,0,-1);


$dates=explode(',',$dates);

$dlen=count($dates);



$weekArray=array("周日","周一","周二","周三","周四","周五","周六");
$dlen=count($dates);
for($a=0;$a<$dlen;$a++)
{  $wek=$dates[$a];
   
   $num=date("w",strtotime($wek));

    $strweek.='"'.$weekArray[$num].'",';
	$strdates.='"'.substr($wek,strpos($wek,'-')+1).'",';
}
$strweek=substr($strweek,0,-1);

$strdates=substr($strdates,0,-1);

$option = '{
                "title" : {
                    "text": "销量"
                },
                "tooltip" : {
                    "trigger": "axis"
                },
                "legend": {
                    "data":["已完成销量","预计销量","下单销量"]
                },
                "toolbox": {
                    "show" : true,
                    "feature" : {
                        "mark" : {"show": true},
                        "dataView" : {"show": true, "readOnly": false},
                        "magicType" : {"show": true, "type": ["line", "bar"]},
                        "restore" : {"show": true},
                        "saveAsImage": {"show": true},
                        "lineStyle" : {
                            "type" : "dashed",
                             "color": "#48b"
                        }
                    }
                },
                "calculable" : true,
                "xAxis" : [
                    {
                        "type" : "category",
                        "boundaryGap" : false,
                        "data" : ['.$strdates.'],
                        "data":['.$strweek.']
                    }
                ],
                "yAxis" : [
                    {
                        "type" : "value",
                        "axisLabel" : {
                            "formatter": "{value}"
                        }
                    }
                ],
                "series" : [
                    {
                        "name":"已完成销量",
                        "type":"line",
                        "data":['.$ti.'],
                        "markPoint" : {
                            "data" : [
                                {"type" : "max", "name": "最大值"},
                                {"type" : "min", "name": "最小值"}
                            ]
                        },
                        "markLine" : {
                           "data" : [
                                {"type" : "average", "name": "平均值"}
                            ]
                        }
                    },
                    {
                        "name":"预计销量",
                        "type":"line",
                        "data":['.$ti2.']
                    },
                    {
                        "name":"下单销量",
                        "type":"line",
                        "data":['.$xiati.'],
                        "markPoint" : {
                            "data" : [
                                {"type" : "max", "name": "最大值"},
                                {"type" : "min", "name": "最小值"}
                            ]
                        },
                        "markLine" : {
                           "data" : [
                                {"type" : "average", "name": "平均值"}
                            ]
                        }
                    }
                ]
            }';
echo $option;